package com.project.livetv.activity;

import android.os.Bundle;
import android.support.v7.widget.RecyclerView;
import android.widget.ListView;

import com.project.livetv.R;
import com.project.livetv.adapter.MyAdapterForMainTv;

import java.util.List;

import io.vov.vitamio.MediaPlayer;
import io.vov.vitamio.widget.VideoView;

public class MainTVShowActivity extends BaseActivity {
    private VideoView mVideoView;
    private RecyclerView mRecyclerView;
    private ListView mListView;
    private MyAdapterForMainTv myAdapterForMainTv;

    //测试数据
    private List<String> mDatas;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main_tvshow);
    }

    @Override
    public void initView() {
        mVideoView = (VideoView) findViewById(R.id.vv_mainTv_showLive);
        mRecyclerView = (RecyclerView) findViewById(R.id.rclv_mainTv_show_watcher);
        mListView = (ListView) findViewById(R.id.lv_main_tv_show_infoshow);

    }

    @Override
    public void initData() {
        mVideoView.setVideoPath("http://pull.a8.com/live/1462882433709831.flv");
        mVideoView.setVideoLayout(VideoView.VIDEO_LAYOUT_STRETCH, 0);
        mVideoView.requestFocus();
        myAdapterForMainTv = new MyAdapterForMainTv(mDatas,this);

    }

    @Override
    public void setData() {
        mListView.setAdapter(myAdapterForMainTv);
        myAdapterForMainTv.notifyDataSetChanged();

    }

    @Override
    public void setListener() {
        mVideoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
            @Override
            public void onPrepared(MediaPlayer mp) {
                mp.setPlaybackSpeed(1.0f);
                mp.start();

            }
        });

    }
}
